package book.dao.Impl;

import org.apache.ibatis.session.SqlSession;

import book.dao.QueryDao;
import book.dao.SqlSessionFactoryUtil;
import book.entity.Book;

public class QueryDaoImpl implements QueryDao {

	public Book queryByName(String name) {
		SqlSession se=null;
		Book book=null;
		try {
			se=SqlSessionFactoryUtil.getSqlSession();
			QueryDao dao=se.getMapper(QueryDao.class);
			book=dao.queryByName(name);
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			se.close();
		}
		return book;
	}

	public Book queryByIsbn(int isbn) {
		SqlSession session=null;
		Book book=null;
		try {
			session=SqlSessionFactoryUtil.getSqlSession();
			QueryDao dao=session.getMapper(QueryDao.class);
			book=dao.queryByIsbn(isbn);
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			session.close();
		}
		return book;
	}

}
